<script setup lang="ts">
import { ref } from 'vue'
import { cssable } from '../models/cssable';
import {fonts} from '../models/fonts';

const props = defineProps<{
    obj:cssable
}>()

const show = ref<boolean>(false);
const obj = ref<cssable>(props.obj);

</script>

<template>
    <div class="config">
        <div @click="show=!show" class="name" :class="{nameShown:show}">
            <slot></slot>
        </div>
        <div v-if="show" class="panel">
            <table>
                <tr>
                    <td>字体颜色</td>
                    <td><input v-model="obj.textColor" type="color"/></td>
                </tr>
                <tr>
                    <td>背景颜色</td>
                    <td><input v-model="obj.backgroundColor" type="color"/></td>
                </tr>
                <tr>
                    <td>字体</td>
                    <td>
                        <select v-model="obj.font">
                            <option v-for="f in fonts" :value="f">
                                {{ f }}
                            </option>
                        </select>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</template>

<style scoped>
select{
    font-size: 16px;
    padding: 1px;
    margin: 1px;
}
.panel{
    display: flex;
    flex-direction: column;
}
.name{
    background-color: #ccc;
    color: black;
    padding: 3px;
    font-size: 18px;
    font-weight: lighter;
    height: 30px;
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.nameShown{
    font-weight: bold;
}
.config{
    margin: 5px;
}
table{
    border-collapse: collapse;
}
table td{
    border-bottom: 1px solid #ccc;
    padding: 3px;
}
</style>